package com.melodyframe.common.context;

public class ContextProxy implements Context {

	private Context			proxyContext;
	private ScopeContext	scopeContext;

	public ContextProxy(Context proxyContext) {
		this.proxyContext = proxyContext;
		this.scopeContext = new HashContext();
	}

	@Override
	public void addScope(String scope, ScopeContext context) {
		this.proxyContext.addScope(scope, context);

	}

	@Override
	public boolean containsKey(Object key) {
		return this.scopeContext.containsKey(key)
				|| this.proxyContext.containsKey(key);
	}

	@Override
	public Object get(Object key) {
		if (this.scopeContext.containsKey(key)) {
			return this.scopeContext.get(key);
		} else {
			return this.proxyContext.get(key);
		}
	}

	@Override
	public Object get(Object key, String scope) {
		return this.proxyContext.get(key, scope);
	}

	@Override
	public Object put(String key, Object value) {
		return this.scopeContext.put(key, value);
	}

	@Override
	public Object put(String key, Object value, String scope) {
		return this.proxyContext.put(key, value);
	}

}
